|
|
|
|
|
|
|
This chapter is for people who learn by example. After the previous edition, many readers wanted even more examples, so based on their suggestions, this chapter includes a hodgepodge of various projects built with Visual Basic. In addition, the projects in this chapter bring together practical applications of information from the other chapters. After you are comfortable with Visual Basic, try some of these things; most of them are even fun! |
|
|
|
|
|
|
|
|
Caller ID with Visual Basic |
|
|
|
|
|
|
|
|
Caller ID is a service provided by the telephone company that lets you know the caller's name and/or number on a display screen, much like an office phone system. The information is transmitted between rings so that you can see the information before picking up the phone. |
|
|
|
|
|
|
|
|
In this age of unsolicited telemarketing calls, Caller ID is a great invention, but of course there's a catch: To screen calls, you have to be near the display unit when the phone ringsthat is, unless you write the Visual Basic program described in this section (see Figure 23.1). This program simulates the standard Caller ID display box with one additionsound. When the phone rings, this program plays a sound file that you assign to a specific caller. For example, you can have the computer sound card scream "Don't answer it!" when the telemarketers make their rounds. |
|
|
|
|
|
|
|
|
Although this application is fairly specific, in building it you learn a way to communicate with a modem from Visual Basic, a technique which can be applied to other areas. |
|
|
|
|
|
|
|
|
Figure 23.1
The Caller ID program alerts you by playing a sound file. |
|
|
|
|
|
|
|
|
Requirements for Using the Sample Program |
|
|
|
|
|
|
|
|
Because this program interacts with the "real world" to some degree, you must follow some basic requirements to use it: |
|
|
|
|
|
|
|
|
You have to subscribe to a Caller ID service. |
|
|
|
|
|
|
|
|
You must have a modem that supports Caller ID data attached to the phone line. |
|
|
|
|
|
|
|
|
You have to know the commands to get your modem to display the data and the exact format in which it will be displayed. |
|
|
|
|
|
|
|
|
Before you even get into Visual Basic, you should determine the commands necessary to use Caller ID with your modem and test it in a terminal program such as HyperTerminal. For example, issuing the command AT#CID=1 to my modem causes it to activate Caller ID display. Then, whenever the phone rings, the information is presented in the terminal session as follows: |
|
|
|
|
|